package com.beauty.dressing.module.main.holder;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.beauty.dressing.R;
import com.beauty.dressing.common.base.BaseRecyclerViewHolder;
import com.beauty.dressing.common.bean.GroupNavigation;
import com.beauty.dressing.module.market.activity.SubMarketActivity;
import com.beauty.dressing.module.market.adapter.MarketMainAdapter;

/**
 * 类描述
 *
 * @author xutingz
 * @email：914603097@qq.com
 */
public class GroupNavHolder extends BaseRecyclerViewHolder<GroupNavigation> {

    private TextView mTitleTxt;
    private TextView mMoreTxt;

    public GroupNavHolder(Context mContext, LayoutInflater mInflater, ViewGroup viewGroup) {
        super(R.layout.market_group_nav, mContext, mInflater, viewGroup);
    }

    @Override
    public void findView() {
        mTitleTxt = (TextView) itemView.findViewById(R.id.title_txt);
        mMoreTxt = (TextView) itemView.findViewById(R.id.more_txt);
    }

    @Override
    public void bindData(final GroupNavigation bean, int position) {
        setVisibility(bean.isVisibility);
        mTitleTxt.setText(bean.title);
        mMoreTxt.setVisibility(bean.showMore? View.VISIBLE:View.GONE);
        mMoreTxt.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (bean.groupNum != 2) {
//                    SubMarketActivity.startActivity(mContext, bean.groupNum);
                }
            }
        });
    }

    public void setVisibility(boolean isVisibility){
        itemView.getLayoutParams().height = isVisibility ? ViewGroup.LayoutParams.WRAP_CONTENT : 0;
        itemView.requestLayout();
    }
}
